<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function Car(name,id,price){
            this.name = name
            this.id = id
            this.price = price
        }
        Car.prototype.run = function(){
            console.log(`${this.name}在跑`);
        }
        Car.prototype.scrapped = function(){
            console.log(`${this.name}报废了`);
        }
        const benz = new Car('benz',123456,'50w')
        const byd = new Car('byd',888888,'20w')
        benz.run()
        byd.run()
        byd.scrapped()

        function Robot(name,elctric,price){
            this.name = name
            this.elctric = elctric
            this.price = price
        }
        Robot.prototype.attack = function(){
            console.log(`${this.name}在战斗`);
        }
        Robot.prototype.transform = function(){
            console.log(`${this.name}变形`);
        }
        const wzt = new Robot('威震天','1100v','200w')
        const dhf = new Robot('大黄蜂','1500v','500w')
        wzt.attack()
        dhf.attack()
        dhf.transform()
    </script>
</body>
</html>